package com.itheima.mapper;

import com.itheima.DTO.YddCateDTO;
import com.itheima.VO.YddCateVO;
import com.itheima.entity.YddCate;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface YddCateMapper {

    @Select("select id, catename, icon, sort_num, default_data from ydd_cate")
    List<YddCate> selectAllCate();

    List<YddCateDTO> page(String catename);

    void addYddCate(YddCate yddCate);

    @Select("select id, catename, icon, sort_num, default_data from ydd_cate where id = #{id}")
    YddCateVO selectCateInfoById(Integer id);

    void updateCate(YddCate yddCate);

    @Delete("delete from ydd_cate where id = #{id}")
    void deleteCateById(Integer id);

    @Select("select count(*) from ydd_cate where catename = #{catename}")
    Integer selectCatenameCount(YddCateDTO yddCateDTO);

    @Select("select count(*) from ydd_cate where catename = #{catename} and id != #{id}")
    Integer selectCatenameCountNotSelf(YddCateDTO yddCateDTO);

    @Select("select count(*) from ydd_cate")
    Integer selectCount();

    List<YddCateDTO> selectList();
}
